package main;

import org.junit.Test;

/**
 * Created by ChengGM on 2016/12/23.
 */
public class BeanCopyTest {
    @Test
    public void test() {

        Bird bird = new Bird();
        bird.setName("xique");
        bird.setAge("12");
        bird.setLeg(5);
        Fly fly = new Fly();
        fly.setName("airplane");
        fly.setAge("50");
        fly.setHeight(500L);

        org.springframework.beans.BeanUtils.copyProperties(bird, fly);
        System.out.println(bird + "-----" + fly);
    }

}

class Bird {
    private String name;
    private String age;
    private int leg;

    public int getLeg() {
        return leg;
    }

    public void setLeg(int leg) {
        this.leg = leg;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Bird{" +
                "name='" + name + '\'' +
                ", age='" + age + '\'' +
                '}';
    }
}

class Fly {
    private String name;
    private String age;
    private Long height;

    public Long getHeight() {
        return height;
    }

    public void setHeight(Long height) {
        this.height = height;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Fly{" +
                "name='" + name + '\'' +
                ", age='" + age + '\'' +
                '}';
    }
}